package com.encryption.util
{
	import mx.formatters.NumberFormatter;
	import mx.utils.StringUtil;

	public class FileUtils
	{
		
		public static function formatFileSize(fileSize:int):String
		{
			var showSize:String;	
			if(fileSize>=0 && fileSize<1024)
				showSize = fileSize + "B";
			else if(fileSize>=1024 && fileSize<(1024*1024))
				showSize = Math.round(fileSize/1024) + "KB";
			else if(fileSize>=(1024*1024) && fileSize<(1024*1024*1024))
				showSize = (fileSize/(1024*1024)).toFixed(2) + "MB";
			else if(fileSize>=(1024*1024*1024))
				showSize = (fileSize/(1024*1024*1024)).toFixed(2) + "GB";
			return showSize;
		}
		
		public static function getFileSuffix(fileFullName:String):String{
			var splitIndex:int = fileFullName.lastIndexOf(".");
			return fileFullName.substring(splitIndex + 1);
		}
		
		public static function getFilePrefix(fileFullName:String):String{
			var splitIndex:int = fileFullName.lastIndexOf(".");
			return fileFullName.substring(0, splitIndex);
		}
	}
}